<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%--<x:parse xml="${param.xmlstr}" var="xmlData" />--%>
<div class="t_bar">
	<%--<span class="color_red">*</span>--%>
	项目基本情况
</div>
<c:set var="nature_value">
	<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />
</c:set>
<table class="t_css" id="basic_tab" width="100%" border="0" cellpadding="0" cellspacing="1">
	<col style="width: 25%" />
	<col style="width: 25%" />
	<col style="width: 20%" />
	<col style="width: 30%" />
	<tr class="li_1">
		<td align="right"><span class="color_red">*</span>项目名称：</td>
		<td colspan="3">
			<input type="text" name="proposal/zh_title" id="project_name" style="width: 98%;" class="required" maxlength="100" value="<x:out select="$xmlData/data/proposal/zh_title"/>" label="项目名称">
		</td>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>归口管理部门：</td>
		<td colspan="3">
			<c:set var="recomend_org">{'id':'<x:out select="$xmlData/data/proposal/recomend_org_value" />','name':'<x:out select="$xmlData/data/proposal/recomend_org_name" />'}</c:set>
			<cpt:tree key="recommended_org" cacheable="false" className="hn_iuput_kuang " readonly="true" value="${recomend_org}" width=""  label="归口管理部门"
					  id="recomend_org" onlyChooseLeaf="false"  showPattern="all" shieldPattern="0" topCheckbox="true" onClick="initTreeValueExt" />
			<input type="hidden" id="recomend_org_value" name="proposal/recomend_org_value"  class="required"  value="<x:out select="$xmlData/data/proposal/recomend_org_value" />" label="归口管理部门">
			<input type="hidden" name="proposal/recomend_org_name" value="<x:out select="$xmlData/data/proposal/recomend_org_name" />">
<%--			申报日期--%>
			<span id="myroot">
			<c:set var="submit_date"><x:out select="$xmlData/data/proposal/submit_date" /></c:set>
			<cpt:date id="submit_date" size="10" name="proposal/submit_date" value="${submit_date}" ></cpt:date>
			</span>
		</td>
<%--		<td  align="right" >申报日期：</td>--%>
<%--		<td >--%>
<%--			<c:set var="submit_date"><x:out select="$xmlData/data/proposal/submit_date" /></c:set>--%>
<%--			<cpt:date id="submit_date" size="10" name="proposal/submit_date" value="${submit_date}" className=" required date " label="申报日期"></cpt:date>--%>
<%--		</td>--%>
	</tr>
	<tr>
		<td align="right"><span class="color_red">*</span>项目联系人姓名：</td>
		<td>
			<input  type="text" label="项目联系人姓名" name="proposal/contact_psn_cname" class="input_css required" maxlength="50" value="<x:out select="$xmlData/data/proposal/contact_psn_cname" />">
		</td>
		<input type="hidden" name="proposal/contact_psn_tel" value="<x:out select="$xmlData/data/organization_persons/organization_person[@psn_type='lianxiren']/contact_tel"/>"/>
		<input type="hidden" name="proposal/contact_psn_email" value="<x:out select="$xmlData/data/organization_persons/organization_person[@psn_type='lianxiren']/contact_email"/>"/>
		<td align="right"><span class="color_red">*</span>联系人手机：</td>
		<td>
			<input type="text" label="联系人手机" name="proposal/contact_psn_mobile" onfocus="InitInput.setNumber(this,11,0,0);" class="input_css required mobile" maxlength="50" value="<x:out select="$xmlData/data/proposal/contact_psn_mobile" />">
		</td>
	</tr>

	<c:if test="${fn:substring(nature_value,0,1) eq 'A'}">
		<tr>
			<td align="right">合作形式：</td>
			<td align="center">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="enterprise_scale" id="jszrEnterpriseScale" value="技术转让" style="margin-left: 10%" onClick="initControlValue(this.id);removeDisabled();">技术转让
				<input type="checkbox" name="enterprise_scale" id="jsxkEnterpriseScale" value="技术许可" style="margin-left: 10%" onClick="initControlValue(this.id);removeDisabled();">技术许可<br>
				<input type="checkbox" name="enterprise_scale" id="zjrgEnterpriseScale" value="作价入股" style="margin-left: 10%" onClick="initControlValue(this.id);">作价入股
				<input type="checkbox" name="enterprise_scale" id="qtEnterpriseScale" value="其他" style="margin-left: 10%" onClick="initControlValue(this.id);">其他
				<input type="hidden" id="enterprise_scale_value" name="proposal/enterprise_scale_value"    value="<x:out select="$xmlData/data/proposal/enterprise_scale_value" />" label="合作形式">
				<input type="hidden" id="technology_enterprise_value" name="proposal/technology_enterprise_value" value="<x:out select="$xmlData/data/proposal/technology_enterprise_value" />">
					<%--<cpt:checkbox key="is_or_no" name="proposal/small_medium_enterprise" repeatColumn="2" tagType="radio"></cpt:checkbox>
                        <input type="hidden" id="prp_date_value" name="proposal/small_medium_enterprise_value" class="required" label="是否中小企业" value="<x:out select="$xmlData/data/proposal/small_medium_enterprise_value" />">
                        <input type="hidden" name="proposal/small_medium_enterprise_name" value="<x:out select="$xmlData/data/proposal/small_medium_enterprise_name" />">--%>
			</td>
			<td align="right"><span class="color_red">*</span>所属领域：</td>
			<td align="left" >

				<c:set var="applicant_subject_value"><x:out select="$xmlData/data/proposal/applicant_subject_value" /></c:set>
				<c:set var="appl_sub_params">
					{'grant_code':'<x:out select="$xmlData/data/proposal/sub_grant_code" />','stat_year':'${param.statYear}'}
				</c:set>
				<input name="proposal/applicant_subject_value" type="hidden" value="<x:out select="$xmlData/data/proposal/applicant_subject_value" />" class="required " label="所属领域"/>
				<input name="proposal/applicant_subject_name" type="hidden" value="<x:out select="$xmlData/data/proposal/applicant_subject_name" />" />
				<cpt:select style="width: 68%;" id="applicant_subject" key="applicant_subject" className="selectWidth2" onChange="initControlValue('applicant_subject')" value="${applicant_subject_value}" sqlParamVal="${appl_sub_params}"></cpt:select>

			</td>
		</tr>

	</c:if>

	<tr>
		<td align="right"><span class="color_red">*</span>项目开始时间：</td>
		<td>
			<c:set var="start_date">
				<x:out select="$xmlData/data/proposal/start_date" />
			</c:set>
			<cpt:date id="start_date" name="proposal/start_date" value="${start_date}" className=" required date   dateCompare:end_date " label="项目开始时间"></cpt:date>
		</td>
		<td align="right"><span class="color_red">*</span>项目结束时间：</td>
		<td >
			<c:set var="end_date">
				<x:out select="$xmlData/data/proposal/end_date" />
			</c:set>
			<cpt:date id="end_date" name="proposal/end_date" value="${end_date}" className=" required date " label="项目结束时间"></cpt:date>
		</td>
	</tr>
	<tr>
<%--		<td align="right">--%>
<%--			<span class="color_red">*</span>项目报审级次：--%>
<%--			<br />--%>
<%--			（省补助资金拨付所属财政局）--%>
<%--		</td>--%>
<%--		<td>--%>
<%--			<c:set var="sub_step">{'id':'<x:out select="$xmlData/data/proposal/sub_step_value" />','name':'<x:out select="$xmlData/data/proposal/sub_step_name" />'}</c:set>--%>
<%--			<cpt:tree key="sub_step" cacheable="false" className="hn_iuput_kuang  " readonly="true" value="${sub_step}" label="项目报审级次" id="sub_step" onlyChooseLeaf="false" showPattern="all" shieldPattern="0"--%>
<%--					  topCheckbox="true" onClick="initTreeValueExt" />--%>
<%--			<input id="sub_step_value" type="hidden" name="proposal/sub_step_value" class="required" label="项目报审级次" value="<x:out select="$xmlData/data/proposal/sub_step_value" />" />--%>
<%--			<input id="sub_step_name" type="hidden" name="proposal/sub_step_name" value="<x:out select="$xmlData/data/proposal/sub_step_name" />" />--%>
<%--		</td>--%>
		<td align="right"><span class="color_red">*</span>项目总投资额：</td>
		<td>
			<input  name="proposal/project_invest" type="text"  style="text-align:right;" onfocus="InitInput.setNumber(this,9,2,2)"
					label="项目总投资额" required class="input_css required " style="ime-mode:disabled;"
					value="<x:out select="$xmlData/data/proposal/project_invest" />" />
		</td>
		<td align="right"><span class="color_red">*</span>项目申请支持金额（万元）：</td>
		<td>
			<input type="text" name="proposal/request_amt" class="required" id="request_amount" onfocus="InitInput.setNumber(this,9,2,2)" style="text-align: right;"
				   value="<x:out select="$xmlData/data/proposal/request_amt"/>" label="项目申请支持金额" onchange="synchronizationAmount();fund_compare()"
			>
		</td>
	</tr>

	<tr>
		<td align="right"><span class="color_red">*</span>项目所属技术合同登记金额（万元）：</td>
		<td>
			<input  name="proposal/registration_amount" type="text"  style="text-align:right;" onfocus="InitInput.setNumber(this,9,2,2)"
					label="项目所属技术合同登记金额" required class="input_css required " style="ime-mode:disabled;"
					value="<x:out select="$xmlData/data/proposal/registration_amount" />" />
		</td>
		<td align="right"><span class="color_red">*</span>项目所属技术合同支付金额<br/>（万元）：</td>
		<td>
			<input type="text" name="proposal/payment_amount" class="required" onfocus="InitInput.setNumber(this,9,2,2)" style="text-align: right;"
				   value="<x:out select="$xmlData/data/proposal/payment_amount"/>" label="项目所属技术合同支付金额"
			>
		</td>
	</tr>

</table>

<div class="t_bar">合作单位信息(最多添加5行) </div>
<table id="inland" border="0" cellspacing="0" cellpadding="0" style="width: 100%" class="table01 t_css">
	<thead>
	<tr >
		<th align="center" width="5%">选择</th>
		<th align="center" width="5%">序号</th>
		<th align="center" width="15%">单位名称</th>
		<th align="center" width="15%">单位地址</th>
		<th align="center" width="15%">合作单位性质</th>
		<th align="center" width="15%">合作形式</th>
		<th align="center" width="10%">合作经费支出（万元）</th>
		<th align="center" width="10%">联系人</th>
		<th align="center" width="10%">电话</th>
		<%--<th align="center" width="20%">分工（限500字）</th>--%>

	</tr>
	</thead>
	<tbody id="inland_tab">
	<tr style="display: none" align="center">
		<td align="center">
			<input type="radio" class="radiobutton" name="selAttendOrg11">
		</td>
		<td align="center">
			<span name="inlands|inland[0]@seq_no">[index]</span>
		</td>
		<td align="center">
			<input name="inlands|inland[0]|org_name" label="单位名称" type="text" onchange="setCooperationUnits();" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100" value="" />
		</td>

		<td align="center">
			<input name="inlands|inland[0]|org_address" label="单位地址" type="text" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100" value="" />
		</td>

		<td align="center">
			<input name="inlands|inland[0]|coop_org_type" label="合作单位性质" type="text" required class="input_css required " style="width: 80%;" maxlength="100" value="" />
		</td>

		<td align="center">
			<input name="inlands|inland[0]|coop_formal" label="合作形式" type="text" required class="input_css required " style="width: 80%;" maxlength="100" value="" />
		</td>

		<td align="center">
			<input name="inlands|inland[0]|coop_fund_expend" label="合作经费支出" type="text" class="input_css required" style="width: 80%;text-align: right;" maxlength="100" value="" onfocus="InitInput.setNumber(this,9,2,2)"  />
		</td>

		<td align="center">
			<input name="inlands|inland[0]|psn_name" label="联系人" type="text" required class="input_css required " maxlength="100" style="width: 80%;" value="" />
		</td>
		<td align="center">
			<input name="inlands|inland[0]|psn_phone" label="电话" type="text" required class="input_css required " maxlength="18" style="width: 80%;" value="" />
		</td>
		<%--<td align="center">
            <input name="inlands|inland[0]|project_division" label="分工" type="text" required class="input_css required " maxlength="500" style="width: 80%;" value="" />
        </td>--%>


	</tr>
	<c:set value="0" var="index" scope="page" />
	<x:forEach select="$xmlData/data/inlands/inland" var="inland">

		<c:choose>
			<c:when test="${index<10}">
				<c:set value="0" var="flag" scope="page" />
			</c:when>
			<c:otherwise>
				<c:set value="" var="flag" scope="page" />
			</c:otherwise>
		</c:choose>
		<tr align="center">
			<td>
				<input type="radio" class="radiobutton" name="selAttendOrg11">
			</td>
			<td align="center">
					<span name="inlands/inland[${flag}${index}]@seq_no">
						<x:out select="$inland/@seq_no" />
					</span>
			</td>
			<td>
				<input name="inlands/inland[${flag}${index}]/org_name" label="单位名称" onchange="setCooperationUnits();" type="text" required class="input_css required maxlength:100" style="width: 80%;" maxlength="100"
					   value="<x:out select="$inland/org_name" />" />
			</td>

			<td align="center">
				<input name="inlands/inland[${flag}${index}]/org_address" label="单位地址" type="text" required class="input_css required maxlength:300" style="width: 80%;" maxlength="100"
					   value="<x:out select="$inland/org_address" />" />
			</td>

			<td align="center">
				<input name="inlands/inland[${flag}${index}]/coop_org_type" label="合作单位性质" type="text" required class="input_css required " style="width: 80%;" maxlength="100"
					   value="<x:out select="$inland/coop_org_type" />" />
			</td>

			<td align="center">
				<input name="inlands/inland[${flag}${index}]/coop_formal" label="合作形式" type="text" required class="input_css required " style="width: 80%;" maxlength="100"
					   value="<x:out select="$inland/coop_formal" />" />
			</td>

			<td align="center">
				<input name="inlands/inland[${flag}${index}]/coop_fund_expend" label="合作经费支出" type="text" required class="input_css " style="width: 80%;text-align: right;" maxlength="100" onfocus="InitInput.setNumber(this,7,2,2)"
					   value="<x:out select="$inland/coop_fund_expend" />" />
			</td>

			<td>
				<input name="inlands/inland[${flag}${index}]/psn_name" label="联系人" type="text" required class="input_css required " style="width: 80%;" maxlength="100"
					   value="<x:out select="$inland/psn_name" />" />
			</td>
			<td>
				<input name="inlands/inland[${flag}${index}]/psn_phone" label="电话" type="text" required class="input_css orgCredit required maxlength:18" style="width: 80%;" maxlength="18"
					   value="<x:out select="$inland/psn_phone" />" />
			</td>

				<%--<td>
					<input name="inlands/inland[${flag}${index}]/project_division" label="分工" type="text" required class="input_css  required maxlength:500" style="width: 80%;" maxlength="500"
						   value="<x:out select="$inland/project_division" />" />
				</td>--%>
		</tr>
		<c:set var="beggerClass"></c:set>
		<c:set value="${index+1}" var="index" scope="page" />
	</x:forEach>
	</tbody>
</table>

<table width="98%" class="not_table">
	<tr>
		<td>
			<input class="button_02" type="button" name="cmdAddbefore" value="添加" onclick="if(checkTabLimit('inland',5,'合作单位信息最多只能填写5条')){addNewRow('inland');change_cs();}try{top.resizeFrame();}catch(e){};setCooperationUnits();" />
			<input class="button_02" name="cmdMovePrev" type="button" value="上移" onclick="movePrev('inland');change_cs();setCooperationUnits()" />
			<input class="button_02" name="cmdMoveNext" type="button" value="下移" onclick="moveNext('inland');change_cs();setCooperationUnits()" />
			<input class="button_02" name="cmddel" type="button" value="删除" onclick="deleteSelectedRow('inland','合作单位信息');change_cs();setCooperationUnits()" />
		</td>
	</tr>
</table>

<input type="hidden" name="proposal/effectivenes_units" id="effectivenes_units" value="<x:out select='$xmlData/data/proposal/effectivenes_units'/>"/>
<input type="hidden" id="age" name="proposal/attach_age" value="<x:out select="$xmlData/data/proposal/attach_age" />"/>

<div class="t_bar"><span class="color_red">*</span>合作单位和项目技术负责人简述(限800字内)</div>
<table id="tblMileStones0" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
	<col style="width:34%"/>
	<col style="width:40%"/>
	<col style="width:13%"/>
	<col style="width:13%"/>
	<tr>
		<td colspan="4">
			<textarea name="project/summary0"  class="input_textarea required maxlength:800" label="合作单位和项目技术负责人简述" rows=5 style="width:98%"><x:out select="$xmlData/data/project/summary0" /></textarea>
			<input type="hidden" name="project/summary0_hidden" id="project/summary0_hidden" value="<x:out select="$xmlData/data/project/summary0" />"/>
		</td>
	</tr>
</table>
<script type="text/javascript">

	function initTreeValueExt(treeId, treeNode) {
		if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
			scmWarn($("#" + treeId).attr("label") + messageTip.researchAreaInvalidDisciplineCode);
			if (treeNode.level == 0) {
				$("#" + treeId).val("");
				$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val("");
				$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val("");
				$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val("");
			}

			return false;
		}


		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}

		$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId+ "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_value'],[id$='" + treeId+ "_value']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId+ "_name']").val(str);
	}

	function setCooperationUnits(){
		var cooperation_units="";
		$("#inland tr:gt(1)").each(function(index){
			var cooperation_unit = $(this).find("td:eq(2) input").val().trim();
			var orgName = $("#org_name").val().trim();
			if(!isBlankOrNull(cooperation_unit) && cooperation_unit!=orgName){
				cooperation_units += cooperation_unit+",";
			}
		});
		if(cooperation_units!=""){
			cooperation_units=cooperation_units.substring(0,cooperation_units.length-1);
		}
		$("#cooperation_units").val(cooperation_units);
	}
	function isBlankOrNull(str){
		if(str.trim()==""){
			return true;
		}else if(str){
			return false;
		}else{
			return true;
		}
	}
	$(document).ready(function(){
		var myDate = new Date();
		var year = myDate.getFullYear();
		var month = myDate.getMonth();
		var day = myDate.getDate();
		var msg=year+'-'+(month+1)+'-'+day;
		$("#submit_date").val(msg);
		// $("#submit_date").css('readonly','true');
		 $("#myroot").css('visibility','hidden');
		// $("#myroot").css('display','none');

		if($('input:checkbox[name="enterprise_scale"]:checked').val()=="中小企业"){
			$("#technologyEnterprise").removeAttr("disabled");
		}else{
			$("#technologyEnterprise").attr("disabled",true);
		}
	});

	/***
	 * 勾选中小型企业框时打开科技型中小企业选择
	 * 没有勾选时关闭科技型中小企业选择，并清除隐藏域的值
	 *
	 */
	function removeDisabled(){
		if($('input:checkbox[name="enterprise_scale"]:checked').val()=="中小企业"){
			$("#technologyEnterprise").removeAttr("disabled");
		}else{
			$("#technologyEnterprise").removeAttr("checked");
			$("#technology_enterprise_value").val("");
			$("#technologyEnterprise").attr("disabled",true);
		}
	};


	function synchronizationAmount(){
		var request_amount=$("#request_amount").val();
		if(request_amount !=  ""){
			$("#total_each_0").val(parseFloat($("#request_amount").val()).toFixed(2));
			$("#total_fund_18").val(parseFloat($("#request_amount").val()).toFixed(2));
		}else if(request_amount ==  ""){
			$("#total_each_0").val("");
			$("#total_fund_18").val("");
		}

	}

	$(function() {
		$("#inland tr:even").addClass("li_1");
		$("#inland tr:odd").addClass("li_2");
	});


	function change_cs(){
		$("#inland tr:even").removeClass().addClass("li_1");
		$("#inland tr:odd").removeClass().addClass("li_2");

	}

	function initSubjectTreeValueExp(treeId, treeNode) {
		/* if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
            // scmWarn($("#" + treeId).attr("label") + "不能选择第一级，请选择它的子级！");
             if (treeNode.level == null) {
                 $("#" + treeId).val("");
                 $("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val("");
                 $("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val("");
             }
             return false;
         }*/
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_code'],[id$='" + treeId + "_code']").val(treeNode.id);
		$("#" + treeId).parents("td").find("[name$='" + treeId + "_name'],[id$='" + treeId + "_name']").val(treeNode.name.substring(treeNode.name.indexOf(".") + 1));
		//触发研究方向
		//checkDisCodeExp(treeNode.id,treeId,true); //下拉树
		//checkDisCodeSelect(treeNode.id,treeId,true);
	}

	function fund_compare() {


		/*  	var total_each =((parseFloat($("#total_each_0").val())*10000 + parseFloat($("#total_each_1").val())*10000 + parseFloat($("#total_each_2").val())*10000 + parseFloat($("#total_each_4").val())*10000)/10000).toFixed(4);
			  /!*var total_each =  (Number($("#total_each_0").val())*100 + Number($("#total_each_1").val())*100 + Number($("#total_each_2").val())*100+ Number($("#total_each_3").val())+ Number($("#total_each_4").val())*100)/100;*!/


			  $("#total_investfrom_5").val(  formatNumberAuto(total_each.toString(), 9, 4, 2));
		  }
	  */

		var ta1 = parseFloat($("#total_each_0").val());

		var ta2 = parseFloat($("#total_each_1").val());
		var ta3 = parseFloat($("#total_each_2").val());
		var ta4 = parseFloat($("#total_each_4").val());
		if (!$.isNumeric(ta1)) {
			ta1 = 0;
		}
		if (!$.isNumeric(ta2)) {
			ta2 = 0;
		}
		if (!$.isNumeric(ta3)) {
			ta3 = 0;
		}
		if (!$.isNumeric(ta4)) {
			ta4 = 0;
		}
		//var ta4 =(ta1+ta2+ta3)*0.1;
		//ta5 = ((parseFloat(ta4)*10000)/10000).toFixed(4);
		ta5 = ((parseFloat(ta1) * 10000 + parseFloat(ta2) * 10000 + parseFloat(ta3) * 10000 + parseFloat(ta4) * 10000) / 10000).toFixed(4);

		//var ta5 =$("#office_szwj_quota").val(ta4)*0.1;
		ta6 = formatNumberAuto(ta5.toString(), 9, 4, 2);
		//var ta =ta6*0.1;


		$("#total_investfrom_5").val(ta6);

	}

</script>
